<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>方案对应运动员表</title>
    <script type="text/javascript" src="../../res/js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="../../js/login_common.js"></script>
    <script type="text/javascript" src="../../layui/layui.js"></script>
    <link rel="stylesheet" href="../../layui/css/layui.css">
</head>
<body>
<div class="demoTable">
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>

<script type="text/html" id="toolbarDemo">
    <div class="layui-inline">
        <input class="layui-input"id="schemeName" name="schemeName"  autocomplete="off" placeholder="请输入运动员姓名">
    </div>
    <div class="layui-input-inline">
        <input type="text" class="layui-input" id="stime" name="stime" placeholder="请输入开始日期" >
    </div>
    <div class="layui-input-inline">
        <input type="text" class="layui-input" id="etime" name="etime"  placeholder="请输入结束日期" >
    </div>

    <input class="layui-btn" type="button" data-type="reload" lay-event="findByKey" id="findByKey" value="搜索"/>
</script>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-bg-blue layui-btn-xs" lay-event="">查看</a>
</script>s

<script>
    var laydate =null;

    var table2 = null;
    layui.use('table', function () {
        var table = layui.table;
        table2 = table.render({
            elem: '#test'
            , url: getRootPath() + 'AtsSchemeAthleteAction/selectAll'
            , where:{remark: "1"}
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }]
            , title: '方案列表'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'saId', title: '序号', width: 80, fixed: 'left',templet: '<div><a class="layui-table-link">{{d.LAY_TABLE_INDEX+1}}</a></div>'}
                , {field: 'schemeName', title: '方案名称', width: 120,  sort: true}
                , {field: 'athleteName', title: '运动员', width: 120, sort: true}
                , {field: 'exp', title: '建议、说明', width: 120}
                , {field: 'isRead', title: '是否查看', width: 100}
                , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 80}
            ]]
            , page: true
        });

        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {

                case 'findByKey':
                    var schemeName=$("#schemeName").val();
                    var stime=$("#stime").val();
                    var etime=$("#etime").val();
                    table2.reload({
                        url: getRootPath() + "AtsSchemeAthleteAction/selectAll",
                        where: {
                            remark:"1"
                            ,schemeName:$("#schemeName").val()
                            ,stime:$("#stime").val()
                            ,etime:$("#etime").val()
                        },
                        page: {
                            curr: 1
                        }
                    });
                    rederTime();
                    //显示搜索的关键字
                    $("#schemeName").val(schemeName);
                    $("#stime").val(stime);
                    $("#etime").val(etime);
                    break;
                //自定义头工具栏右侧图标 - 提示
                case 'LAYTABLE_TIPS':
                    layer.alert('这是工具栏右侧自定义的一个图标按钮');
                    break;
            }
        });



        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
           if (obj.event === 'look') {
               //iframe层
                layer.open({
                    type : 2,
                    title : '方案维护页面',//标题
                    shadeClose : true,
                    shade : 0.3,//背景阴影
                    area : [ '700px','677px' ],//大小
                    content : '.html?schemeId='+data.schemeId, //iframe的url
                    end : function() {
                        table2.reload();//渲染
                    }
                });
            }
        });
    });
    layui.use('laydate', function () {
        laydate = layui.laydate;
        //开始时间、结束时间
        laydate.render({
            elem: '#stime',
            trigger: 'click'
        });

        laydate.render({
            elem: '#etime',
            trigger: 'click'
        });
    });

    /**
     * 刷新时间控件
     */
    function rederTime(){
        laydate.render({
            elem: '#stime',
            trigger: 'click'
        });

        laydate.render({
            elem: '#etime',
            trigger: 'click'
        });
    }

</script>
</body>
</html>